package main 

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	file, err := os.OpenFile("D:/dev/golang/dadi/test.txt", os.O_CREATE | os.O_RDWR | os.O_APPEND, 0666)
	defer file.Close()
	if (err != nil) {
		fmt.Println("open file error:", err)
		return
	}
	writer := bufio.NewWriter(file)
	defer writer.Flush()
	for i := 0; i < 10; i++ {
		writer.WriteString("hello world" + strconv.Itoa(i) + "\r\n")
	}
}